home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / utils / error / assert.c next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.5 KB  |  65 lines

  1. /*
  2.  * assert.c --
  3.  *    Assert code.
  4.  *
  5.  * Note:
  6.  *    This should eventually work with elog(), dlog(), etc.
  7.  */
  8.  
  9. #include <stdio.h>
  10.  
  11. #include "tmp/c.h"
  12. #include "utils/module.h"
  13.  
  14. RcsId("$Header: /private/postgres/src/utils/error/RCS/assert.c,v 1.9 1991/11/11 19:31:43 mer Exp $");
  15.  
  16. #include "utils/exc.h"
  17.  
  18. /*
  19.  * There might be a need to specially handle FailedAssertion, below.
  20.  *
  21. #include "excid.h"    // for FailedAssertion
  22.  */
  23.  
  24. void
  25. ExceptionalCondition(conditionName, exceptionP, detail, fileName, lineNumber)
  26.     const String    conditionName;
  27.     const Exception    *exceptionP;
  28.     const String    detail;
  29.     const String    fileName;
  30.     const int    lineNumber;
  31. {
  32.     extern String ExcFileName;    /* XXX */
  33.     extern Index ExcLineNumber;    /* XXX */
  34.  
  35.     ExcFileName = fileName;
  36.     ExcLineNumber = lineNumber;
  37.  
  38.     if (!PointerIsValid(conditionName)
  39.             || !PointerIsValid(fileName)
  40.             || !PointerIsValid(exceptionP)) {
  41.         fprintf(stderr, "ExceptionalCondition: bad arguments\n");
  42.  
  43.         ExcAbort(exceptionP, 
  44.              (ExcDetail)detail,
  45.              (ExcData)NULL,
  46.              (ExcMessage)NULL);
  47.     } else {
  48.         fprintf(stderr,
  49.             "%s(\"%s:%s\", File: \"%s\", Line: %d)\n",
  50.             exceptionP->message, conditionName, detail,
  51.             fileName, lineNumber);
  52.     }
  53.  
  54.     /*
  55.      * XXX Depending on the Exception and tracing conditions, you will
  56.      * XXX want to stop here immediately and maybe dump core.
  57.      * XXX This may be especially true for Assert(), etc.
  58.      */
  59.  
  60.     /* TraceDump();    /* dump the trace stack */
  61.  
  62.     /* XXX FIXME: detail is lost */
  63.     ExcRaise(exceptionP, (ExcDetail)0, (ExcData)NULL, conditionName);
  64. }
  65.